package net.qiqbframework.springboot.autoconfig;


import net.qiqbframework.domains.event.infra.persistence.DomainEventPersistence;
import net.qiqbframework.eventsourcing.dao.DomainEventDao;
import net.qiqbframework.eventsourcing.dao.DomainEventFeedbackDao;
import net.qiqbframework.eventsourcing.dao.DomainEventSubscriptionDao;
import net.qiqbframework.event.dao.mpimpl.*;
import net.qiqbframework.mp.MybatisPlusCondition;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;


@AutoConfiguration
@ConditionalOnClass(MybatisPlusCondition.class)
@MapperScan(basePackageClasses = {DomainEventMapper.class, DomainEventProcessMapper.class})
public class MybatisPlusModuleAutoConfiguration {

    @Bean
    public DomainEventPersistence qiqbDomainEventPersistence(DomainEventDao domainEventDao, DomainEventSubscriptionDao domainEventSubscriptionDao, DomainEventFeedbackDao domainEventFeedbackDao) {
        return new DomainEventPersistence(domainEventDao, domainEventSubscriptionDao, domainEventFeedbackDao);
    }

    @Bean
    public DomainEventDao qiqbDomainEventDao() {
        return new DomainEventDaoMpImpl();
    }

    @Bean
    public DomainEventSubscriptionDao qiqbDomainEventSubscriptionDao() {
        return new DomainEventSubscriptionDaoMpImpl();
    }

    @Bean
    public DomainEventFeedbackDao qiqbDomainEventFeedbackDao() {
        return new DomainEventFeedbackDaoMpImpl();
    }

}
